package org.lzfto.flink.demo.business.flinkTest.flinkObjects.sink;

import java.io.IOException;

import org.apache.flink.api.connector.sink2.InitContext;
import org.apache.flink.api.connector.sink2.Sink;
import org.apache.flink.api.connector.sink2.SinkWriter;
import org.apache.flink.api.connector.sink2.WriterInitContext;

/**
*自定义输出，用于把结果输出到一个websocket中..
*@author lzfto
*@创建时间 2025年6月18日 11:23:24
*/
public class SimpleWebSocketSink<T> implements Sink<T> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String webSocketClientName;
	private String messagePrefix;
	
	public SimpleWebSocketSink(String webSocketClientName) {
		super();
		this.webSocketClientName=webSocketClientName;
		this.messagePrefix="";
	}
	
	public SimpleWebSocketSink(String webSocketClientName,String messagePrefix) {
		super();
		this.webSocketClientName=webSocketClientName;
		this.messagePrefix=messagePrefix;
	}

	@Override
	public SinkWriter<T> createWriter(WriterInitContext context) throws IOException {
		return new CustWebSocketSinkWriter<T>(webSocketClientName,messagePrefix);
	}

	public SinkWriter<T> createWriter(InitContext context) throws IOException {
		return null;
	}

}
